package com.qinggeng.project.tool.third.service.impl;

import com.qinggeng.common.utils.DateUtils;
import com.qinggeng.project.tool.third.domain.SysThird;
import com.qinggeng.project.tool.third.mapper.SysThirdMapper;
import com.qinggeng.project.tool.third.service.ISysThirdService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 第三方登录Service业务层处理
 *
 * @author qinggeng
 * @date 2020-03-13
 */
@Service
public class SysThirdServiceImpl implements ISysThirdService
{
    @Resource
    private SysThirdMapper sysThirdMapper;

    /**
     * 查询第三方登录
     *
     * @param thirdId 第三方登录ID
     * @return 第三方登录
     */
    @Override
    public SysThird selectSysThirdById(Long thirdId)
    {
        return sysThirdMapper.selectSysThirdById(thirdId);
    }

    /**
     * 查询第三方登录列表
     *
     * @param sysThird 第三方登录
     * @return 第三方登录
     */
    @Override
    public List<SysThird> selectSysThirdList(SysThird sysThird)
    {
        return sysThirdMapper.selectSysThirdList(sysThird);
    }

    /**
     * 新增第三方登录
     *
     * @param sysThird 第三方登录
     * @return 结果
     */
    @Override
    public int insertSysThird(SysThird sysThird)
    {
        sysThird.setCreateTime(DateUtils.getNowDate());
        return sysThirdMapper.insertSysThird(sysThird);
    }

    /**
     * 修改第三方登录
     *
     * @param sysThird 第三方登录
     * @return 结果
     */
    @Override
    public int updateSysThird(SysThird sysThird)
    {
        sysThird.setUpdateTime(DateUtils.getNowDate());
        return sysThirdMapper.updateSysThird(sysThird);
    }

    /**
     * 批量删除第三方登录
     *
     * @param thirdIds 需要删除的第三方登录ID
     * @return 结果
     */
    @Override
    public int deleteSysThirdByIds(Long[] thirdIds)
    {
        return sysThirdMapper.deleteSysThirdByIds(thirdIds);
    }

    /**
     * 删除第三方登录信息
     *
     * @param thirdId 第三方登录ID
     * @return 结果
     */
    @Override
    public int deleteSysThirdById(Long thirdId)
    {
        return sysThirdMapper.deleteSysThirdById(thirdId);
    }

    @Override
    public SysThird selectSysThirdByPlatform(String platformCode, String openId) {
        return sysThirdMapper.selectSysThirdByPlatformOpenId(platformCode,openId);
    }

    @Override
    public SysThird selectSysThirdByUnionId(String[] platformTypes, String unionId) {
        return sysThirdMapper.selectSysThirdByUnionId(platformTypes,unionId);
    }

    @Override
    public int updateSysThirdByUserId(Long userId, Long oldUserId) {
        return sysThirdMapper.updateSysThirdByUserId(userId, oldUserId);
    }

    @Override
    public SysThird selectSysThirdByCode(String platform, String code) {
        return sysThirdMapper.selectSysThirdByCode(code,platform);
    }

}
